/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.game.stepbystep;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.IOException;

/**
 * @author zinin
 */
public class GameDesign {
    
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Image topview_tiles;
    private TiledLayer orchard;
    private Sprite fatman;
    public int fatmanseq001Delay = 200;
    public int[] fatmanseq001 = {88, 89, 90, 91, 92};
    private Image sprite_selection;
    private Sprite selmark;
    public int selmarkseq001Delay = 200;
    public int[] selmarkseq001 = {0, 1, 2, 1, 0};
//</editor-fold>//GEN-END:|fields|0|
    
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
//</editor-fold>//GEN-END:|methods|0|

    public void updateLayerManagerForWorld(LayerManager lm) throws java.io.IOException {//GEN-LINE:|1-updateLayerManager|0|1-preUpdate
        // NOTE : items are listed in reversed Z-Order
        getSelmark().setPosition(0, 0);
        getSelmark().setVisible(false);
        lm.append(getSelmark());
        getFatman().setPosition(149, 101);
        getFatman().setVisible(true);
        lm.append(getFatman());
        getOrchard().setPosition(0, 0);
        getOrchard().setVisible(true);
        lm.append(getOrchard());        
        getFatman().setPosition(243, 127);//GEN-BEGIN:|1-updateLayerManager|1|1-postUpdate
        getFatman().setVisible(true);
        lm.append(getFatman());
        getOrchard().setPosition(0, 0);
        getOrchard().setVisible(true);
        lm.append(getOrchard());//GEN-END:|1-updateLayerManager|1|1-postUpdate
        // write post-update user code here
    }//GEN-LINE:|1-updateLayerManager|2|

    public Image getTopview_tiles() throws java.io.IOException {//GEN-BEGIN:|2-getter|0|2-preInit
        if (topview_tiles == null) {//GEN-END:|2-getter|0|2-preInit
            // write pre-init user code here
            topview_tiles = Image.createImage("/topview_tiles.png");//GEN-BEGIN:|2-getter|1|2-postInit
        }//GEN-END:|2-getter|1|2-postInit
        // write post-init user code here
        return this.topview_tiles;//GEN-BEGIN:|2-getter|2|
    }//GEN-END:|2-getter|2|

    public TiledLayer getOrchard() throws java.io.IOException {//GEN-BEGIN:|3-getter|0|3-preInit
        if (orchard == null) {//GEN-END:|3-getter|0|3-preInit
            // write pre-init user code here
            orchard = new TiledLayer(20, 20, getTopview_tiles(), 16, 16);//GEN-BEGIN:|3-getter|1|3-midInit
            int[][] tiles = {
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 16, 13, 16, 16, 16, 16, 16, 27, 25, 25},
                {16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 15, 16, 16, 16, 16, 16, 26, 16, 16},
                {16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 16, 16, 16, 16, 16, 26, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, 10, 16, 16, 16, 16, 16, 26, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 15, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 15, 16},
                {16, 16, 16, 3, 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 15, 16},
                {16, 16, 16, 3, 3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 15, 16},
                {16, 16, 16, 3, 3, 27, 25, 25, 25, 25, 25, 25, 25, 28, 16, 16, 16, 26, 16, 16},
                {16, 16, 16, 10, 10, 3, 44, 31, 31, 31, 31, 31, 32, 26, 16, 16, 16, 26, 16, 16},
                {16, 16, 16, 10, 9, 3, 47, 60, 60, 60, 60, 60, 48, 30, 25, 25, 25, 29, 16, 16},
                {16, 16, 16, 10, 10, 10, 47, 60, 60, 60, 60, 60, 48, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 46, 64, 64, 64, 64, 64, 45, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
                {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}
            };//GEN-END:|3-getter|1|3-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|3-getter|2|3-postInit
                for (int col = 0; col < 20; col++) {
                    orchard.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|3-getter|2|3-postInit
        // write post-init user code here
        return orchard;//GEN-BEGIN:|3-getter|3|
    }//GEN-END:|3-getter|3|

    public Sprite getFatman() throws java.io.IOException {//GEN-BEGIN:|4-getter|0|4-preInit
        if (fatman == null) {//GEN-END:|4-getter|0|4-preInit
            // write pre-init user code here
            fatman = new Sprite(getTopview_tiles(), 16, 16);//GEN-BEGIN:|4-getter|1|4-postInit
            fatman.setFrameSequence(fatmanseq001);//GEN-END:|4-getter|1|4-postInit
            // write post-init user code here
        }//GEN-BEGIN:|4-getter|2|
        return fatman;
    }//GEN-END:|4-getter|2|

    public Image getSprite_selection() throws java.io.IOException {//GEN-BEGIN:|6-getter|0|6-preInit
        if (sprite_selection == null) {//GEN-END:|6-getter|0|6-preInit
            // write pre-init user code here
            sprite_selection = Image.createImage("/sprite_selection.png");//GEN-BEGIN:|6-getter|1|6-postInit
        }//GEN-END:|6-getter|1|6-postInit
        // write post-init user code here
        return this.sprite_selection;//GEN-BEGIN:|6-getter|2|
    }//GEN-END:|6-getter|2|

    public Sprite getSelmark() throws java.io.IOException {//GEN-BEGIN:|7-getter|0|7-preInit
        if (selmark == null) {//GEN-END:|7-getter|0|7-preInit
            // write pre-init user code here
            selmark = new Sprite(getSprite_selection(), 16, 16);//GEN-BEGIN:|7-getter|1|7-postInit
            selmark.setFrameSequence(selmarkseq001);//GEN-END:|7-getter|1|7-postInit
            // write post-init user code here
        }//GEN-BEGIN:|7-getter|2|
        return selmark;
    }//GEN-END:|7-getter|2|
    
}
